/*******************************************************************************
 * AAEngine
 * Copyright (c) 2010 Mike Jarosch
 *
 * This file is licensed under the terms of the MIT license, which is included
 * in the "MIT License.txt" file at the root directory of this SDK.
 ******************************************************************************/

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using AAEngine.Engine;
using AAEngine.GameComponents;
using AAEngine.Screens;

using AAEngineTest.Screens;

namespace AAEngineTest
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : AAGame
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            Components.Add(new FPSOverlay(this));

#if WINDOWS_PHONE
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            graphics.IsFullScreen = true;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
#endif
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            AAGame.RegisterAssembly("AAEngine");
            AAGame.RegisterAssembly("AAEngine.Box2D");
            AAGame.RegisterAssembly("AAEngineTest");
            AAGame.RegisterAssembly("Box2D.XNA");
#if WINDOWS_PHONE || XBOX
            AAGame.RegisterAssembly("Microsoft.Xna.Framework");
#endif

#if XBOX
            SplashScreen splashScreen = new SplashScreen("Images/logo", 2f, 0.5f, 0.5f, new BackgroundScreen("Images/background"), new MainMenuScreen(PlayerIndex.One));
#else
            SplashScreen splashScreen = new SplashScreen("Images/logo", 2f, 0.5f, 0.5f, new BackgroundScreen("Images/background"), new MainMenuScreen(null));
#endif

            ScreenManager.AddScreen(splashScreen);

            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            LevelManager.Load("levelDescriptions");
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //// Allows the game to exit
            //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            //    this.Exit();

            //// TODO: Add your update logic here

            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //GraphicsDevice.Clear(Color.Black);

            //// TODO: Add your drawing code here

            base.Draw(gameTime);
        }
    }
}
